/**
*   \file   intersect.h
*   \author Dave Reid
*   \brief  Main header file for checking for intersections between different shapes.
*/
#ifndef __EAGL_INTERSECT_H_
#define __EAGL_INTERSECT_H_

#include "intersect/spheresphere.h"
#include "intersect/spherepoint.h"
#include "intersect/sphereray.h"
#include "intersect/spheresegment.h"
#include "Intersect/sphereplane.h"

#include "intersect/aabbaabb.h"
#include "intersect/aabbpoint.h"
#include "intersect/aabbray.h"


namespace eagl
{

/**
*   \brief              Determines if two shapes intersect.
*   \param  shape0 [in] The first shape to check for intersection.
*   \param  shape1 [in] The second shape to check for intersection.
*   \return             True if the two shapes are intersection or are just touching.
*/
inline bool intersect(const Sphere &sphere0, const Sphere &sphere1)
{
    return intersect_spheresphere(sphere0.getPosition(), sphere0.getRadius(), sphere1.getPosition(), sphere1.getRadius());
}
inline bool intersect(const Sphere &sphere, const Point3 &point)
{
    return intersect_spherepoint(sphere.getRadius(), sphere.getPosition(), point.getPosition());
}
inline bool intersect(const Sphere &sphere, const Ray &ray)
{
    return intersect_sphereray(sphere.getRadius(), sphere.getPosition(), ray.getOrigin(), ray.getDirection());
}
inline bool intersect(const Sphere &sphere, const Segment3 &segment)
{
    return intersect_spheresegment(sphere.getRadius(), sphere.getPosition(),
        segment.getStartPoint().getPosition(), segment.getEndPoint().getPosition());
}
inline bool intersect(const Sphere &sphere, const Plane &plane)
{
    return intersect_sphereplane(sphere.getRadius(), sphere.getPosition(), plane.getNormal(), plane.getDistance());
}


inline bool intersect(const AABB &aabb0, const AABB &aabb1)
{
    return intersect_aabbaabb(aabb0.getExtents(), aabb0.getPosition(), aabb1.getExtents(), aabb1.getPosition());    
}
inline bool intersect(const AABB &aabb, const Point3 &point)
{
    return intersect_aabbpoint(aabb.getExtents(), aabb.getPosition(), point.getPosition());
}
inline bool intersect(const AABB &aabb, const Ray &ray)
{
    return intersect_aabbray(aabb.getExtents(), aabb.getPosition(), ray.getOrigin(), ray.getDirection());
}



}

#endif  // __EAGL_INTERSECT_H_